package valueObject;

import entity.Professor;
import entity.University;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;

/**
 *
 * @author Juan Hernández Serrato
 */
public class UniversityVO implements ValueObject<University> {
    private String userName;
    private String name;
    private String address;
    private String phoneNumber;
    private String type;
    private String web;
    private Date joinDate;
    private String description;
    private String location;
    private byte[] image;
    private Collection<ProfessorVO> professors;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String universityUser) {
        this.userName = universityUser;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getWeb() {
        return web;
    }

    public void setWeb(String web) {
        this.web = web;
    }

    public Date getJoinDate() {
        return joinDate;
    }

    public void setJoinDate(Date joinDate) {
        this.joinDate = joinDate;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public byte[] getImage() {
        return image;
    }

    public void setImage(byte[] image) {
        this.image = image;
    }

    public Collection<ProfessorVO> getProfessors() {
        return professors;
    }

    public void setProfessors(Collection<ProfessorVO> professorCollection) {
        this.professors = professorCollection;
    }
    
    @Override
    public University toEntity() {
        University university = new University();
        university.setAddress(address);
        university.setDescription(description);
        university.setImage(image);
        university.setJoinDate(joinDate);
        university.setLocation(location);
        university.setName(name);
        university.setPhoneNumber(phoneNumber);
        ArrayList<Professor> professorsE = new ArrayList<Professor>();
        if(professors != null){
            for(ProfessorVO p : professors){
                professorsE.add(p.toEntity());
            }
        }
        university.setProfessorCollection(professorsE);
        university.setType(type);
        university.setUniversityUser(userName);
        university.setWeb(web);
        return university;
    }
}
